package com.android.myfilm.activities;

import com.android.myfilm.tools.Utils;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.KeyEvent;

public class MoviesList extends ListActivity {
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
	  super.onCreate(savedInstanceState);
	  
	  new ProgressTask(this).execute();
	}
	
	@Override
	protected void onResume() {
		super.onRestart();
		
		checkNetwork();
	}
	
	public boolean onKeyUp(int keyCode, KeyEvent event) {
	    if (keyCode == KeyEvent.KEYCODE_BACK) {
	    	finish();
	    }
	    return true;
	}
	
	private void checkNetwork() {
		if (!Utils.isOnline(this)) {
			Utils.showToast("Network unavailable", this);
			finish();
		}
	}
}
